#include<iostream>
#include<cstring>
using namespace std;
const int N = 15;
bool st[N][N];

int cnt;

int t, n, m;
void dfs(int x, int y, int sum)
{
	if (sum == n * m) {
		cnt++;
		return;
	}
	int dx[] = { -2,-2,-1,1,2,2,1,-1 };
	int dy[] = { -1,1,2,2,1,-1,-2,-2 };
	for (int i = 0; i < 8; i++) {
		int a = x + dx[i];
		int b = y + dy[i];
		if (a<0 || a>=n || b<0 || b>=m || st[a][b])continue;
		st[a][b] = 1;
		dfs(a, b, sum + 1);
		st[a][b] = 0;
	}
}
int main()
{
	cin >> t;
	while (t--) {
		memset(st, 0, sizeof(st));
		cnt = 0;
		cin >> n >> m;
		int x, y;
		cin >> x >> y;
		st[x][y] = 1;
		dfs(x, y, 1);
		cout << cnt << endl;
	}
	return 0;
}